<?php
/**
 * 广告列表模板
 */

use yii\helpers\Html;
use kartik\grid\GridView;


$this->title = '广告管理';

$gridColumns = [
    ['class' => 'yii\grid\SerialColumn'],
    'title',
    'adPosition.title',
    [
        'attribute' => 'url',
        'format' => 'html',
        'value' => function($model){
            return '<a href="'.$model->url.'" target="_blank">链接地址'.$model->url.'</a>';
        }
    ],
    [
        'attribute' => 'status',
        'value' => function($model){
            return $model->status ? "显示" : "隐藏";
        }
    ],
    [
        'attribute' => 'content',
        'format' => 'html',
        'value' => function($model){
            return '<a href="'.$model->content.'" target="_blank">新窗口打开</a>';
        }
    ],
    'admin.realName',
    'createTime:datetime',
    'updateTime:datetime',
    [
        'class' => 'common\widgets\KartikActionColumn',
        'items' => [
            ['修改', 'ad/edit', 'btn-primary'],
        ]
    ],

];

echo GridView::widget([
    'dataProvider' => $dataProvider,
    'panel' => [
        'type' => GridView::TYPE_DEFAULT,
        'heading' => '广告列表',
    ],
    'toolbar' => [
        ['content' => Html::a('<i class="glyphicon glyphicon-plus"></i> 添加广告', ['ad/add'], ['class' => 'btn btn-primary'])],        '{toggleData}'
    ],
    'columns' => $gridColumns,
]);

